package com.xiu.travel.portal;

import com.alibaba.fastjson2.JSON;
import com.xiu.travel.portal.client.OrderClient;
import com.xiu.travel.portal.result.ApiResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 搜索
 * </p>
 *
 * @author YuLing
 * @since 2023-10-13
 */
@RestController
@RequestMapping("/portal/admin/distribution/order")
@Tag(name = "订单接口")
public class OrderController {
    @Autowired
    private OrderClient orderClient;

    @PostMapping("submit")
    @Operation(summary = "创单-提交订单")
    public ApiResult submit(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.submit(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("cancel")
    @Operation(summary = "创单-取消订单")
    public ApiResult cancel(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.cancel(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("detail")
    @Operation(summary = "创单-查询订单详情")
    public ApiResult detail(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.detail(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }



    @PostMapping("confirm")
    @Operation(summary = "出票-出票前确认")
    public ApiResult confirm(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.confirm(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("issue")
    @Operation(summary = "出票-提交出票（改期）")
    public ApiResult issue(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.issue(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }


    @PostMapping("ticket/rule")
    @Operation(summary = "退票-查询退改规则")
    public ApiResult ticketRule(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.ticketRule(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("ticket/rule/fee")//todo
    @Operation(summary = "退票-查询退改手续费")
    public ApiResult ticketRuleFee(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.ticketRuleFee(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("refund/submit")//todo
    @Operation(summary = "退票-提交退票申请")
    public ApiResult refundSubmit(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.refundSubmit(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }


    @PostMapping("ticket/can/refund1")
    @Operation(summary = "退票-查询是否可退")
    public ApiResult ticketCanRefund(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.ticketCanRefund(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("change/flight/list")
    @Operation(summary = "改期-查询改期航班列表")
    public ApiResult changeFlightList(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.changeFlightList(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("change/confirm")
    @Operation(summary = "改期-改期前确认")
    public ApiResult changeConfirm(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.changeConfirm(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("change/submit")
    @Operation(summary = "改期-提交改期申请")
    public ApiResult changeSubmit(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.changeSubmit(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("attachment/upload")
    @Operation(summary = "改期-上传退改证明材料")
    public ApiResult attachmentUpload(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.attachmentUpload(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }

    @PostMapping("attachment/submit")
    @Operation(summary = "改期-提交退改证明材料")
    public ApiResult attachmentSubmit(@RequestBody Object dto) {
        return JSON.parseObject(orderClient.attachmentSubmit(dto, OpenFeignConfig.TOKEN), ApiResult.class);
    }



}
